//
//  SCButtonTraverCollectionReusableView.m
//  LastOne
//
//  Created by dllo on 15/11/7.
//  Copyright © 2015年 sc. All rights reserved.
//

#import "SCButtonTraverCollectionReusableView.h"
#import "ClickButton.h"
#import "NightHeader.h"
#import "FitHeader.h"
//延展
@interface SCButtonTraverCollectionReusableView ()
@property(nonatomic, retain)UIImageView *imageView;
@property(nonatomic, retain)ClickButton *button1;
@property(nonatomic, retain)ClickButton *button2;
@property(nonatomic, retain)ClickButton *button3;
@property(nonatomic, retain)ClickButton *button4;
@property(nonatomic, retain)ClickButton *button5;
@property(nonatomic, retain)ClickButton *button6;
@property(nonatomic, retain)ClickButton *button7;
@property(nonatomic, assign)NSInteger selectButton;
@end

@implementation SCButtonTraverCollectionReusableView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height - 50 * FitHeight)];
        _imageView.image = [UIImage imageNamed:@"map"];
        [self addSubview:_imageView];
        _selectButton = 1111;
        
        _button1 = [[ClickButton alloc] initWithFrame:CGRectMake(275 * FitWidth, 60 * FitHeight, 60 * FitWidth, 50 * FitHeight)];
        _button1.backgroundColor = [UIColor clearColor];
        _button1.tag = 1111;
        _button1.myLabel.textColor = [UIColor colorWithRed:0.32 green:0.79 blue:0.64 alpha:1];
        _button1.myLabel.text = @"亚洲";
        [_button1 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_button1];
        
        _button2 = [[ClickButton alloc] initWithFrame:CGRectMake(175 * FitWidth, 45 * FitHeight, 60 * FitWidth, 50 * FitHeight)];
        _button2.backgroundColor = [UIColor clearColor];
        _button2.tag = 1112;
        _button2.myLabel.text = @"欧洲";
        [_button2 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_button2];
        
        _button3 = [[ClickButton alloc] initWithFrame:CGRectMake(52 * FitWidth, 50 * FitHeight, 60 * FitWidth, 50 * FitHeight)];
        _button3.backgroundColor = [UIColor clearColor];
        _button3.tag = 1113;
        _button3.myLabel.text = @"北美洲";
        [_button3 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_button3];
        
        _button4 = [[ClickButton alloc] initWithFrame:CGRectMake(100 * FitWidth, 125 * FitHeight, 60 * FitWidth, 50 * FitHeight)];
        _button4.backgroundColor = [UIColor clearColor];
        _button4.tag = 1114;
        _button4.myLabel.text = @"南美洲";
        [_button4 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_button4];
        
        _button5 = [[ClickButton alloc] initWithFrame:CGRectMake(306 * FitWidth, 142 * FitHeight, 60 * FitWidth, 50 * FitHeight)];
        _button5.backgroundColor = [UIColor clearColor];
        _button5.tag = 1115;
        _button5.myLabel.text = @"大洋洲" ;
        [_button5 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_button5];
        
        _button6 = [[ClickButton alloc] initWithFrame:CGRectMake(190 * FitWidth, 90 * FitHeight, 60 * FitWidth, 50 * FitHeight)];
        _button6.backgroundColor = [UIColor clearColor];
        _button6.tag = 1116;
        _button6.myLabel.text = @"非洲";
        [_button6 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_button6];
        
        _button7 = [[ClickButton alloc] initWithFrame:CGRectMake(270 * FitWidth, 200 * FitHeight, 60 * FitWidth, 50 * FitHeight)];
        _button7.backgroundColor = [UIColor clearColor];
        _button7.tag = 1117;
        _button7.myLabel.text = @"南极洲";
        [_button7 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_button7];
        
        //热门旅游的标题
        _label = [[UILabel alloc] initWithFrame:CGRectMake(_imageView.frame.origin.x + 5 * FitWidth, _imageView.frame.origin.y + _imageView.frame.size.height + 5 * FitHeight, frame.size.width - 10 * FitWidth, 40 * FitHeight)];
        _label.font = [UIFont fontWithName:@"Helvetica-Bold" size:15 * FitWidth];
        [_label NightWithType:UIViewColorType2];
        [self addSubview:_label];
    }
    return self;
}

-(void)buttonAction:(ClickButton *)button
{
    self.block(button.tag - 1111);
    button.myLabel.textColor = [UIColor colorWithRed:0.32 green:0.79 blue:0.64 alpha:1];
    //    [button.myImageView setBackgroundColor:[UIColor colorWithRed:0.32 green:0.79 blue:0.64 alpha:1]];
    ClickButton *lastButton = (ClickButton *)[self viewWithTag:_selectButton];
    lastButton.myLabel.textColor = [UIColor blackColor];
    //    [lastButton.myImageView setBackgroundColor:[UIColor clearColor]];
    _selectButton = button.tag;
}


@end
